home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: argc/argv & switches
- Date: 7 Mar 96 22:34:30 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.826238070@rscernix>
- References: <4h2j8j$9gn@milo.freenet.vancouver.bc.ca> <danpop.825593142@rscernix> <313E0094.167EB0E7@fore.com> <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
-
- >However, if it were the case that these pointers are not modifiable,
-
- It _is_ the case. An attempt to modify a pointer from the argv "array"
- results in undefined behaviour.
-
- >would not the declaration of main() be required to be written as:
- >
- >int main(int argc, char * const *argv)
- >
- > or
- >
- >int main(int argc, char * const argv[])
- >
- >That is, ``argv is a pointer to a vector of constant pointers to modifiable
- >chars''.
-
- The key point here is backward compatibility with K&R C, which didn't
- have the 'const' modifier.
-
- A similar case is the type of a string literal, which is char[] and not
- const char[], even if you're not allowed to modify a string literal.
- The reason is the same: backward compatibility.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-